package com.example.snackbar;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ListView;
import android.widget.Toast;

import com.google.android.material.snackbar.Snackbar;

public class MainActivity extends AppCompatActivity {
    private Button button;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        button = (Button) findViewById(R.id.button);

        initView();
    }

    public void initView2(View view){
        Persion persion = new Persion();
        persion.setAge(5);
        persion.setName("alice");
        Intent intent = new Intent(MyApplication.getContext(),MainActivity2.class);
        intent.putExtra("persion",persion);
        startActivity(intent);
    }
    
    public void initView(){
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Snackbar.make(v,"Data deleted",Snackbar.LENGTH_SHORT)
                        .setAction("Undo",new View.OnClickListener(){
                            @Override
                            public void onClick(View v) {
                                Toast.makeText(MainActivity.this, MyApplication.getContext().getPackageName(), Toast.LENGTH_SHORT).show();
                            }
                        })
                        .show();
            }
        });
    }

    public void show(View view){
        Intent intent = new Intent(MainActivity.this,normalListView.class);
        startActivity(intent);
    }
    public void showSelf(View view){
        Intent intent = new Intent(MainActivity.this,selfListView.class);
        startActivity(intent);
    }

    public void showRecycleView(View view){
        Intent intent = new Intent(MainActivity.this,RecycleView.class);
        startActivity(intent);
    }

}